package com.bookmanage.dao;

import com.bookmanage.utils.DBUitls;

import java.sql.*;

public class BookAddConn {
    public static void add(int isbn, int price, String author, String publish, String bookname) {
        try {

            String sql = "insert into book values(?,?,?,?,?)";
            //预处理编译sql
            PreparedStatement pst = (PreparedStatement) DBUitls.getConn().prepareStatement(sql);
            //设置数据库的五个参数
            pst.setInt(1, isbn);
            pst.setString(2, bookname);
            pst.setInt(3, price);
            pst.setString(4, author);
            pst.setString(5, publish);
            pst.executeUpdate();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
